<div id="modals">
    <!--modals-->
    <div class="modal fade" id="modal-add" role="basic" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h4 class="modal-title">新增</h4>
                </div>
                <div class="modal-body">
                    <form action="javascript:" method="post">
                        <table class="table table-striped table-bordered " width="100%">
                            <tr>
                                <th>类型</th>
                                <td>
                                    <select class="form-control  input-medium inline" name="houseType">
                                        <option value="20007">保税仓</option>
                                        <option value="20008">直邮地</option>
                                    </select>
                                </td>
                            </tr>

                            <tr>
                                <th>编号</th>
                                <td><input type="text" class="form-control  input-medium inline" name="houseNo"
                                           value=""></td>
                            </tr>
                            <tr>
                                <th>名称</th>
                                <td><input type="text" class="form-control  input-medium inline" name="houseName"
                                           value=""></td>
                            </tr>

                            <tr>
                                <th>商品免运费金额</th>
                                <td><input type="number" min="0" max="9999" class="form-control  input-small inline"
                                           name="freePost" placeholder="包邮填写0" value="0"></td>
                            </tr>
                        </table>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn dark green btn-save radius6"><i class="fa fa-check"></i> 保存
                    </button>
                    <button type="button" class="btn dark  btn-outline radius6" data-dismiss="modal"><i
                            class="fa fa-close"></i> 关闭
                    </button>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="modal-edit" role="basic" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                    <h4 class="modal-title">修改</h4>
                </div>
                <div class="modal-body">
                    <form action="javascript:" method="post">
                        <input type="hidden" name="id" value="">
                        <table class="table table-striped table-bordered " width="100%">
                            <tr>
                                <th>类型</th>
                                <td>
                                    <select class="form-control  input-medium inline" name="houseType">
                                        <option value="20007">保税仓</option>
                                        <option value="20008">直邮地</option>
                                    </select>
                                </td>
                            </tr>

                            <tr>
                                <th>编号</th>
                                <td><input type="text" class="form-control  input-medium inline" name="houseNo"
                                           value=""></td>
                            </tr>
                            <tr>
                                <th>名称</th>
                                <td><input type="text" class="form-control  input-medium inline" name="houseName"
                                           value=""></td>
                            </tr>

                            <tr>
                                <th>商品免运费金额</th>
                                <td><input type="number" min="0" max="9999" class="form-control  input-small inline"
                                           name="freePost" placeholder="包邮填写0" value="0"></td>
                            </tr>
                        </table>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn dark green btn-save radius6"><i class="fa fa-check"></i> 保存
                    </button>
                    <button type="button" class="btn dark  btn-outline radius6" data-dismiss="modal"><i
                            class="fa fa-close"></i> 关闭
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row">
    <div class="top-handle-btn">
        <!--search-form-->
        <form id="search-form" action="javascript:;">
            <a type="button" class="btn green right  radius6" href="#modal-add" data-toggle="modal"><i class="fa fa-plus"></i> 新增</a>
            <button class="btn purple right search radius6" style="display: none;"><i class="fa fa-search"></i> 查询</button>
        </form>
    </div>
</div>
<div class="row">

    <!--main-content-->
    <table id="data-table" class="table table-striped table-bordered table-hover" width="100%">
        <thead>
        <tr>
            <th>编号</th>
            <th>类型</th>
            <th>名称</th>
            <th>免运费</th>
        </tr>
        </thead>
        <tbody>
        </tbody>
        <tfoot>
        </tfoot>
    </table>
</div>

<!--table-data-loader-->
<script type="text/javascript">
    var resourceUrl = "/warehouse";


    $(function () {
        DataTable.init({
            url: resourceUrl, //ajax请求url
            tableName: "data-table", //数据表table id
            paramsFormName: "search-form", //查询参数form id
            modal: "modals", //模态框div
            columns: [ //列对应的字段数组，注意顺序
                {
                    data: "houseNo"
                },
                {
                    data: "houseType",
                    replaceFn:"replaceDataDict"
                },
                {
                    data: "branchId",
                    visible: false
                },
                {
                    data: "houseName",
                },
                {
                    data: "freePost",
                },
            ],
            options: [ //操作区域(id)
                {
                    icon: "fa fa-edit",
                    name: "编辑",
                    option: "modal-edit",
                    edit: true,
                    editMain:true,
                    url: resourceUrl + "/{id}",
                },
                {
                    icon: "fa fa-remove",
                    name: "删除",
                    del: resourceUrl,
                },
            ],
        });

        $("select").select2();

        $("#modal-add").find("button[type=submit]").on("click",function () {
            Shinez.post(resourceUrl,$("#modal-add").find("form").serialize(),function (ret) {
                if(ret.status==0){
                    $("#modal-add").modal('hide');
                    $(".search").trigger("click");
                }
                if(ret.status==-1){
                    Shinez.tip("error",ret.info);
                }
            })
        });
    });
</script>